package com.moneytree.action;

import java.util.Date;

import com.moneytree.model.Loan;
import com.moneytree.service.LoanService;
import com.moneytree.utils.ActionUtils;
import com.moneytree.utils.Page;

public class LoanAction extends ActionUtils {
	private static final long serialVersionUID = 1L;

	private Loan loan;
	private Page page;

	private LoanService loanService;

	public String loan(){
		loan = loanService.queryById(loan.getId());
		return SUCCESS;
	}
	
	public String loanList(){
		if(loan==null){
			loan = new Loan();
		}
		if(page==null){
			page = new Page();
			page.setCurrentPage(1);
			page.setPageSize(10);
		}
		page = loanService.queryBean(loan, page);
		return SUCCESS;
	}
	
	public String toAddLoan(){
		return SUCCESS;
	}
	
	public String addLoan(){
		System.out.println("jinrufangfa");
		loan.setAddtime(new Date());
		loanService.save(loan);
		System.out.println(loan.getTitle());
		return SUCCESS;
	}
	
	public Loan getLoan() {
		return loan;
	}

	public void setLoan(Loan loan) {
		this.loan = loan;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public LoanService getLoanService() {
		return loanService;
	}

	public void setLoanService(LoanService loanService) {
		this.loanService = loanService;
	}

}
